<template>
  <VFormRender :form-json="formJson"></VFormRender>
</template>

<script>
import VFormRender from '@/components/form-render/index.vue'

export default {
  name: 'RenderApp',
  components: {
    VFormRender,
  },
  data() {
    return {
      formJson: {
        'widgetList': [],
        'formConfig': {
          'modelName': 'formData',
          'refName': 'vForm',
          'rulesName': 'rules',
          'labelWidth': 80,
          'labelPosition': 'left',
          'size': '',
          'labelAlign': 'label-left-align',
          'cssCode': '',
          'customClass': '',
          'functions': '',
          'layoutType': 'PC',
          'onFormCreated': '',
          'onFormMounted': '',
          'onFormDataChange': '',
          'onFormValidate': '',
        },
      },
    }
  },
  created() {
    console.log('render created')
  },
  mounted() {
    console.log('render mounted')
    // 从localStorage获取表单配置和组件列表
    const widgetList = window.localStorage.getItem('widget__list__backup')
    const formConfig = window.localStorage.getItem('form__config__backup')
    if (widgetList) {
      this.formJson.widgetList = JSON.parse(widgetList)
    }
    if (formConfig) {
      this.formJson.formConfig = JSON.parse(formConfig)
    }
    console.log('formJson', this.formJson)
  },
}
</script>

<style lang="scss">

</style>